using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel;

namespace ERPBackend.Models
{
    public class Inventory : BaseModel
    {
        [Required]
        public int MaterialId { get; set; }

        [Required]
        public int WarehouseId { get; set; }

        [StringLength(50)]
        public string? BatchNumber { get; set; }

        [Required]
        [Column(TypeName = "decimal(18,4)")]
        public decimal CurrentStock { get; set; }

        [Column(TypeName = "decimal(18,4)")]
        public decimal SafetyStock { get; set; }

        [Column(TypeName = "decimal(18,4)")]
        public decimal MaxStock { get; set; }

        [Required]
        [StringLength(50)]
        public string Unit { get; set; } = string.Empty;

        [Column(TypeName = "decimal(18,4)")]
        public decimal StockAmount { get; set; }

        public DateTime? LastStockInDate { get; set; }

        public DateTime? LastStockOutDate { get; set; }

        [Required]
        [DefaultValue(1)]
        public byte Status { get; set; } = 1; // 0: 预警, 1: 正常, 2: 超储

        // 导航属性
        [ForeignKey("MaterialId")]
        public Material? Material { get; set; }

        [ForeignKey("WarehouseId")]
        public Warehouse? Warehouse { get; set; }
    }
}